<?php


namespace app\api\validate;


use think\Validate;

class OrderValidate extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'use_type' => ['require', 'in:mini,pc,app'],
        'goods_id' => ['require', 'gt:0'],
        'goods_spec_id' => ['require', 'gt:0'],
        'num' => ['require', 'gt:0'],
        'user_address_id' => ['require'],
        'user_coupon_id' => ['require'],
        'cart_ids' => ['require'],
        'pay_type' => ['require', 'in:wallet,wechat'],
        'place_type' => ['require', 'in:goods,cart'],
        'order_id' => ['require', 'gt:0'],
        'order_goods_id' => ['require', 'gt:0'],
        'type' => ['require', 'in:1,2'],
        'refund_price' => ['require','gt:0'],
        'images' => ['require'],
        'start_time' => ['require','date'],
        'end_time' => ['require','date'],
        'order_express_id' => ['require'],
        'goods_params' => ['require'],
        'dispatch_type' => ['require','in:express,ziti'],
//        'shop_id' => ['require'],
    ];

    /**
     * 提示消息
     */
    protected $message = [];

    /**
     * 验证场景
     */
    protected $scene = [
        'confirmOrder' => ['use_type','goods_params','user_address_id','user_coupon_id','confirmOrder'],
        'goodsConfirmOrder' => ['use_type','goods_id','goods_spec_id','num','user_address_id','user_coupon_id','confirmOrder'],
        'cartConfirmOrder' => ['use_type','cart_ids','user_address_id','user_coupon_id','confirmOrder'],
        'placeOrder' => ['use_type','place_type','user_address_id','user_coupon_id','dispatch_type'],
        'getOrderDetail' => ['order_id'],
        'cancelOrder' => ['order_id'],
        'deleteOrder' => ['order_id'],
        'confirmReceipt' => ['order_id'],
        'applyRefundInfo' => ['order_id','order_goods_id'],
        'applyRefund' => ['type','order_id','order_goods_id','refund_price','num'],
        'getExpressList' => ['order_id'],
        'express' => ['order_express_id'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'use_type' => '设备端',
            'goods_id' => '商品ID',
            'goods_spec_id' => '商品规格ID',
            'num' => '数量',
            'cart_ids' => '购物车ID',
            'user_address_id' => '地址ID',
            'user_coupon_id' => '优惠券ID',
            'pay_type' => '支付方式',
            'place_type' => '下单类型',
            'order_id' => '订单ID',
            'start_time' => '筛选开始时间',
            'end_time' => '筛选结束时间',
            'shop_id' => '店铺ID',
        ];
        parent::__construct($rules, $message, $field);
    }
}